package com.lanbu.system.service.impl;

import com.lanbu.system.domain.mongo.MongoTeamMembers;
import com.lanbu.system.mapper.MongoTeamMembersRepository;
import org.bson.types.ObjectId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class MongoTeamMembersService {

    private final MongoTeamMembersRepository teamMembersRepository;

    @Autowired
    public MongoTeamMembersService(MongoTeamMembersRepository teamMembersRepository) {
        this.teamMembersRepository = teamMembersRepository;
    }


    public List<MongoTeamMembers> findAll() {
        return teamMembersRepository.findAll();
    }

    public List<MongoTeamMembers> findByTeamId(ObjectId teamId) {
        return teamMembersRepository.findByTeamId(teamId);
    }

    public Optional<MongoTeamMembers> findById(ObjectId id) {
        return teamMembersRepository.findById(id);
    }


    public MongoTeamMembers save(MongoTeamMembers teamMember) {
        return teamMembersRepository.save(teamMember);
    }


    public void deleteById(ObjectId id) {
        teamMembersRepository.deleteById(id);
    }

    public MongoTeamMembers findByUserId(ObjectId userId){
        return teamMembersRepository.findByUserId(userId);
    }
}
